<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>背景样式</title>
    <style>
        .c1{
            width: 300px;
            height: 200px;
            background-color: red;
        }
        /*
            当同时设置背景图与背景色,背景图生效
        */
        .c2{
            width: 2000px;
            height: 1000px;
            /*background-color: green;*/
            /*background-image: url('../images/3.jpg');*/
            /*background-attachment: fixed;*/
            background: red url('../images/3.jpg') no-repeat center fixed;
        }
        /*
            当背景图没有铺满整个区域时,设置背景色后在没有背景图的区域使用背景色
        */
        .c3{
            width: 300px;
            height: 200px;
            background-image: url('../images/heihei.gif');
            background-repeat: no-repeat;
            background-color: red;
            background-position: left top;
        }
        .c4{
            width: 300px;
            height: 200px;
            background-image: url('../images/heihei.gif');
            background-repeat: no-repeat;
            background-position: 10% 50%;
            background-color: red;
        }
        .c5{
            width: 300px;
            height: 200px;
            background: green url('../images/heihei.gif') no-repeat center;
        }
    </style>
</head>
<body>
<div class="c1"></div>
<hr>
<div class="c2"></div>
<hr>
<div class="c3"></div>
<hr>
<div class="c4"></div>
<hr>
<div class="c5"></div>
</body>
</html>